// 后台实时数据推送
const signalR = require("@microsoft/signalr")

export function createSignalR(url) {
    let conn = new signalR.HubConnectionBuilder()
        .withUrl(url)
        .withAutomaticReconnect()
        .build();
    return conn;
}

export function isConnected(conn) {
    if (conn && conn != undefined && conn != null && conn.state != signalR.HubConnectionState.Disconnected) {
        return true;
    } else {
        return false;
    }
}

export function isAlive(conn) {
    if (conn && conn != undefined && conn != null && conn.state == signalR.HubConnectionState.Connected) {
        return true;
    } else {
        return false;
    }
}